﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Globalization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Taxonomy;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.Office.DocumentManagement.DocumentSets;

namespace JobCreateInDocs3
{

    [Guid("75AEAF20-A2C2-4318-BA81-F701A7D570B2")]
    public class JobCreateInDocs : SPJobDefinition
    {
        #region Propertys
        private string _DisplayName =
  @"(Ko) Import new documents (bill), ver. 3.0.0.11";
        public override string DisplayName
        {
            get
            {
                return _DisplayName;
            }
        }
        private string _Description =
  @"(Ko) Импорт новых накладных. Загружаются из AXAPTA через заданное время по таймеру. "
+ @"Настройка коннекта к базе и глубина выборки в днях находятся к глобальных настройках Ko";
        public override string Description
        {
            get
            {
                return _Description;
            }
        }
        #endregion Propertys
        #region Members
        string sUrl = @"http://localhost/sites/shop/";
        string sListName = "Первичные документы";
        Ko2.Portal.Env _env = new Ko2.Portal.Env();
        #endregion #region Members
        #region Constructors
        public JobCreateInDocs()
            : base()
        {
            this.Title = _DisplayName;
        }
        public JobCreateInDocs(string jobName, SPService service, SPServer server, SPJobLockType targetType)
            : base(jobName, service, server, targetType)
        {
            this.Title = _DisplayName;
        }
        public JobCreateInDocs(string jobName, SPWebApplication webApplication)
            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = _DisplayName;
        }
        #endregion Constructors
        #region Common Methods
        static public string StringConvertName(String mName)
        {
            return mName.Replace("\"", "'"); ;
        }
        #endregion Common Methods
        #region Job Methods
        public Exception Execute(Guid contentDbId, string siteStr)
        {
            Exception ret = null;
            if (Ko2.Sys.Net.NetInfo.MachineName.ToLower() != "s-wss02")
                return ret;
            JobCreateInDocs_Process.Execute(contentDbId, siteStr, this);
            return ret;
        }
        public override void Execute(Guid contentDbId)
        {
            if (Ko2.Sys.Net.NetInfo.MachineName.ToLower() != "s-wss02")
                return;
            Exception err = Execute(contentDbId, sUrl);
            string DomainNameStr = _env.GetAppSetting("DomainName");
        }
        #endregion Job Methods
    }

}
